{include file="public/layout" /}
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page min-hg-c-10">
    {include file="search/bar" /}
    <div class="flexigrid">
        <div class="mDiv pt0">
            <div class="ftitle">
                {eq name="'Search@batch_add'|is_check_access" value="1"}
                <div class="fbutton">
                    <a href="javascript:void(0);" data-href="{:url('Search/batch_add')}" onclick="openFullframe(this, '批量新增', '600px', '600px');">
                        <div class="add">
                            <span><i class="layui-icon layui-icon-addition"></i>批量新增</span>
                        </div>
                    </a>
                </div>
                {/eq}
            </div>
            <form class="navbar-form form-inline" id="searchForm" action="{:url('Search/index')}" method="get" onsubmit="layer_loading('正在处理');">
                {$searchform.hidden|default=''}
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="关键词搜索...">
                        <input type="submit" class="btn" value="搜索">
                        <i class="iconfont e-sousuo"></i>
                    </div>
                    <div class="fbutton">
                        <a href="javascript:void(0);" onclick="ExcelExport(this);" data-url="{:url('Search/ajax_excel_export')}" class="bt-xin-xia ml10" style="line-height: 28px;"><i class="iconfont e-xiazai"></i>导出</a>
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w40" axis="col0">
                            <div class="tc"><input type="checkbox" autocomplete="off" class="checkAll"></div>
                        </th>
                        <th abbr="article_show" axis="col5" class="w80">
                            <div class="tc">ID</div>
                        </th>
                        <th abbr="ac_id" axis="col4">
                            <div class="text-l10">关键字</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w150">
                            <div class="tc sort_style"><a href="{:getArchivesSortUrl('searchNum')}">搜索次数&nbsp;<i {eq name='$Request.param.orderby' value='searchNum'}{eq name='$Request.param.orderway' value='asc'}class="asc"{else /}class="desc"{/eq}{/eq}></i></a></div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w80">
                            <div class="tc">热搜</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w100">
                            <div class="tc">搜索结果</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w150">
                            <div class="tc">最后搜索时间</div>
                        </th>
                        <th axis="col1" class="w80">
                            <div class="tc">操作</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr>
                            <td class="sign">
                                <div class="w40 tc"><input type="checkbox" autocomplete="off" name="ids[]" value="{$vo.id}"></div>
                            </td>
                            <td class="sort">
                                <div class="w80 tc">
                                    {$vo.id}
                                </div>
                            </td>
                            <td style="width: 100%">
                                <div class="text-l10">
                                    <input type="text" value="{$vo.word}" style="width: 95%;" data-id="{$vo.id}" onchange="c_submit('word',this);">
                                </div>
                            </td>
                            <td>
                                <div class="tc w150">
                                    <input type="text" value="{$vo.searchNum}" style="width: 100px;text-align: center;" data-id="{$vo.id}" onchange="c_submit('searchNum',this);">
                                </div>
                            </td>
                            <td>
                                <div class="tc w80">
                                    {if condition="$vo['is_hot'] eq 1"}
                                        <span class="yes" onClick="changeTableVal('search_word','id','{$vo.id}','is_hot',this);"{/eq}><i class="fa fa-check-circle"></i>是</span>
                                    {else /}
                                        <span class="no" onClick="changeTableVal('search_word','id','{$vo.id}','is_hot',this);"{/eq}><i class="fa fa-ban"></i>否</span>
                                    {/if}
                                </div>
                            </td>
                            <td class="">
                                <div class="w100 tc">
                                    {$vo.resultNum}
                                </div>
                            </td>
                            <td class="">
                                <div class="w150 tc">
                                    {$vo.update_time|date='Y-m-d H:i:s',###}
                                </div>
                            </td>
                            <td class="operation">
                                <div class="w80 tc">
                                    {eq name="'Search@del'|is_check_access" value="1"}
                                    <a class="btn red"  href="javascript:void(0)" data-url="{:url('Search/del')}" data-id="{$vo.id}" onClick="delfun(this);">删除</a>
                                    {/eq}
                                    
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        {notempty name="list"}
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton checkboxall">
                    <input type="checkbox" autocomplete="off" class="checkAll">
                </div>
                {eq name="'Search@del'|is_check_access" value="1"}
                <div class="fbutton">
                    <a onclick="batch_del(this, 'ids');" data-url="{:url('Search/del')}" data-id="{$vo.id}" class="layui-btn layui-btn-primary">
                        <span>批量删除</span>
                    </a>
                </div>
                {/eq}
                {include file="public/page" /}
            </div>
            <div style="clear:both"></div>
        </div>
        {/notempty}
    </div>
</div>
<script>
    // AJAX调用下载
    function ExcelExport(obj) {
        layer_loading('导出中');
        $.ajax({
            type: 'post',
            url : $(obj).attr('data-url'),
            data: {
                _ajax: 1,
            },
            dataType: 'json',
            success: function(res) {
                layer.closeAll();
                if (1 == res.code) {
                    window.location.href = res.url;
                } else {
                    showErrorAlert(res.msg);
                }
            },
            error: function(e) {
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }

    function c_submit(field,obj){
        layer_loading('正在处理');
        $.ajax({
            type : 'post',
            url : "{:url('Search/edit')}",
            data :{id:$(obj).attr('data-id'),field:field,value:$(obj).val(),_ajax:1},
            dataType : 'json',
            success : function(res){
                layer.closeAll();
                if(res.code == 1){
                    layer.msg(res.msg);
                }else{
                    showErrorMsg(res.msg);
                }
            },
            error: function(e){
                layer.closeAll();
                layer.alert(e.responseText, {icon: 5, title:false});
            }
        })
    }

    $(function(){
        $('input[name*=ids]').click(function(){
            if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
                $('.checkAll').prop('checked','checked');
            } else {
                $('.checkAll').prop('checked', false);
            }
        });
        $('input[type=checkbox].checkAll').click(function(){
            $('input[type=checkbox]').prop('checked',this.checked);
        });

        $('#searchForm select[name=groupid]').change(function(){
            $('#searchForm').submit();
        });
    });
    
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });
</script>

{include file="public/footer" /}